/** *******************************************************************
 * FlexDatabaseManager
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.flexdatabasemanager.vo
{
	import com.adobe.cairngorm.vo.IValueObject;
	import com.jonniespratley.flexdatabasemanager.utils.ByteUtils;
		

	[Bindable]
	public class SizeVO extends Object implements IValueObject
	{
		public var aTotalSize:String;
		public var aDataSize:String;
		public var aIndexSize:String;
		
		public function  SizeVO( obj:Object = null )
		{	
			if ( obj != null )
			{
				this.aTotalSize = this.formatSize( obj['totalSize'], ByteUtils.KBYTES );
				this.aDataSize = this.formatSize( obj['dataSize'], ByteUtils.KBYTES );
				this.aIndexSize = this.formatSize( obj['indexSize'], ByteUtils.KBYTES );	
			} 
		}
		
		private function formatSize( oldSize:String, newSizeType:int ):String
		{
			var byteUtil:ByteUtils = new ByteUtils();
			var formatted:String = byteUtil.format( Number( oldSize ), newSizeType, 2 );
				
			return formatted;
		}
		
		public function get totalSize():String
		{
			return aTotalSize;
		}
	}
}